package com.demo.print;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Test {
    public static void main(String[] args) {
        LocalDate date = LocalDate.of(2018, 1, 2);
        String s1 = date.format(DateTimeFormatter.BASIC_ISO_DATE);
        System.out.println(s1);

        String s2 = date.format(DateTimeFormatter.ISO_LOCAL_DATE);
        System.out.println(s2);

        LocalDate date1 = LocalDate.parse("20180102", DateTimeFormatter.BASIC_ISO_DATE);
        System.out.println(date1);

        LocalDate date2 = LocalDate.parse("2018-01-02", DateTimeFormatter.ISO_LOCAL_DATE);
        System.out.println(date2);

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
        String formattedDate = date1.format(formatter);
        System.out.println(formattedDate);
        LocalDate date3 = LocalDate.parse(formattedDate, formatter);
        System.out.println(date3);
    }
}
